home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 February
/
EnigmA AMIGA RUN 34 (1999)(G.R. Edizioni)(IT)[!][issue 1999-02].iso
/
www
/
amitrix
/
as.lha
/
AutoSearch
/
AutoSearch.awebrx
next >
Wrap
Text File
|
1998-02-21
|
5KB
|
208 lines
/*
$VER: AutoSearch 2.4 (21.2.98) by Gabriele Favrin (favrin@tin.it)
*/
options results
parse ARG args
parse SOURCE . . called .
domain = ".com"
cfg = findpath(called)||"autosearch.cfg"
multi = 1
eol = '0A'x
servercfg = ""
server = 1
s.1.url="http://altavista.digital.com/cgi-bin/query?pg=q&q="
s.1.name="AltaVista"
s.2.url="http://www-english.lycos.com/cgi-bin/pursuit?cat=lycos&mtemp=lite&terse=&query="
s.2.name="Lycos"
s.3.url="http://search.yahoo.com/bin/search?p="
s.3.name="Yahoo"
s.4.url="http://www.excite.com/search.gw?search="
s.4.name="Excite"
s.5.url="http://www.nlsearch.com/nlquery.fcg?sb=Search&si=&us=025&cc=&qr="
s.5.name="Northern Light"
If (args == "") | (args == "%3F") then do
If Exists(cfg) then do
Call LoadCFG()
end
else do
s.1.use=1
end
Call CreateHTMLCFG()
Call SendToAWeb('T:autosearchCFG.html')
end
else do
If Left(args, 1) == "." then do
Call ParseACFG()
Call SaveCFG()
end
else do
If Exists(cfg) then do
Call LoadCFG()
End
else do
s.1.use=1
End
If Left(args, 1) == "@" then do
url='http://www.'Right(args, Length(args)-1)||domain
'UrlField SET' url
'Open "'url'"'
end
else do
Call DoSearch()
end
end
end
exit 0
ParseACFG:
fp=Pos(' ', args)-1
interpret SubStr(args, 2, fp)
sp=Pos('server', args)
If sp ~= 0 then do
multi=0
do while (sp ~= 0)
interpret SubStr(args, sp, 11)
s.server.use=1
servercfg=servercfg||server||eol
multi=multi+1
sp=Pos('server', args, sp+10)
end
end
else do
interpret Right(args, Length(args)-1)
multi=1
servercfg="1"||eol
end
return
CreateHTMLCFG:
ct=1
html='<html><head><title>AutoSearch configuration page</title></head><body><table border align=center><tr valign=top align=center><td><form name="config" action="x-aweb:rexx/'called'">Domain for default name completion<br><input size=6 name=".domain" value="'domain'"><br>(eg. <code>.com , .it , .nl</code>)<td>Search Engines:<br><select name="server" multiple>'
do while s.ct.name ~== "S."ct".NAME"
html=html||'<option value="'ct'"'
If (s.ct.use == 1) then do
html=html||' selected>'s.ct.name' '
end
else do
html=html||'>'s.ct.name' '
end
ct=ct+1
end
html=html||'</select><tr><td colspan=2 align=center><input type="submit" value="Save Configuration"></form></table></body></html>'
return
SendToAWeb:
parse ARG file
If Open(fp, file, 'W') then do
Call WriteLN(fp, html)
Call Close(fp)
'AllowCMD'
'Open file:///'file' RELOAD'
'Wait file:///'file
'UrlField SET "AutoSearch 2.4"'
address command 'Delete >NIL: QUIET "'file'"'
end
else do
'Request "AutoSearch" "Can''t create temporary file." "_Ok" NOWAIT'
end
return
LoadCFG:
If Open(fp, cfg, 'R') then do
domain=ReadLN(fp)
multi=ReadLN(fp)
do ct=1 to multi
server=ReadLN(fp)
s.server.use=1
end
Call Close(fp)
end
else do
'Request "AutoSearch" "Can''t read configuration" "_Ok" NOWAIT'
end
return
SaveCFG:
If Open(fp, cfg, 'W') then do
Call WriteCH(fp, domain||eol||multi||eol||servercfg)
end
else do
'Request "AutoSearch" "Can''t save configuration" "_Ok" NOWAIT'
end
return
DoSearch:
searchtext=args
If (multi == 1) then do
'Open "'s.server.url||searchtext'" RELOAD'
end
else do
'Get ACTIVEPORT VAR' port
tempfile="t:autosearch."Right(port, Length(port)-Pos('.', port))".html"
ct=1
html="<html><head><title>Search results for ""args""</title></head><body>"
'GetCFG FRAMES VAR' frames
If frames then do
html=html||'<div align="center" id="'top'">'
server_html=""
head_html=""
do while s.ct.name ~== "S."ct".NAME"
If (s.ct.use == 1) then do
head_html=head_html||'<a href="#'ct'">'s.ct.name' results</a> '
server_html=server_html||'<p><iframe src="'s.ct.url||searchtext'" width="95%" height="83%" id="'ct'"></iframe><p><a href="'#top'">Back to top</a>'
end
ct=ct+1
end
html=html||head_html||server_html||'<p>'head_html'</div></body></html>'
end
else do
head_html=""
server_html="<h1>Search ""args"" on:</h1><p><ul>"
do while s.ct.name ~== "S."ct".NAME"
If (s.ct.use == 1) then do
server_html=server_html||'<li><a href="'s.ct.url||searchtext'">'s.ct.name'</a>'
end
ct=ct+1
end
html=html||head_html||server_html||head_html'</ul></body></html>'
end
Call SendToAWeb(tempfile)
end
return
findpath:
procedure
parse ARG pathf
dir_pos = Max(lastpos('/', pathf), lastpos(':', pathf))
If dir_pos > 0 then
return(left(pathf,dir_pos))
else
return('')